macromedia Your Account International Help
Products Support & Training DevNet Solutions Partners Downloads Store
Products Support & Training DevNet Solutions Partners Downloads Store
Home > Products > Dreamweaver > Support > TechNote Index
Macromedia Dreamweaver Support Center - TechNote

Some PHP code is not colored correctly in Code view

Issue
When inserting PHP output tags starting with <?=, Dreamweaver MX does not recognize the code as valid PHP. Therefore, the code is not colored as PHP code, and the tag color given for it in Code view is similar to that of html tags.

A code sample that Dreamweaver would color incorrectly would be either <?= "Dreamweaver MX"?> or <?="Dreamweaver MX"?>.

Reason
Although these tags are valid PHP, they use a shorthand syntax and Dreamweaver MX does not recognize them by default. When coloring the code, Dreamweaver references an application file named codecoloring.xml to determine if the code uses recognizable syntax.

Since this syntax is not included in the file by default, Dreamweaver doesn't recognize code using this syntax as valid PHP.

Solution
This issue can be fixed by editing the codecoloring.xml files inside the Dreamweaver MX configuration folders.

Note: Multiuser platforms (Windows XP, 2000 and NT, or Macintosh OS X) allow multiple users to access applications and settings unique to them. To take advantage of this feature, Dreamweaver MX will store unique customizations and settings within user-specific folders.

This prevents a user's settings, snippets and site definitions from overwriting other users' settings. Therefore, the codecoloring.xml file must be changed different locations according to the platform.
1 Locate the codecoloring.xml file for Dreamweaver MX.
  Multiuser platforms (Windows XP, 2000 and NT, and Macintosh OSX)
> Windows XP and Windows 2000:
C:\Documents and Settings\username\Application Data\Macromedia\Dreamweaver MX\Configuration\Code Coloring\
> Windows NT:
C:\WINNT\Profiles\username\Application Data\Macromedia\
Dreamweaver MX\Configuration\Code Coloring\
> Macintosh OS X:
Hard disk:Users:username:Library:Application Support:Macromedia:Dreamweaver MX:Configuration: Code Coloring:

Single user platforms (Windows 98 and ME, and Macintosh OS 9.x)
> Windows 98/ME: (default installation location)
C:\Program Files\Macromedia\Dreamweaver MX\Configuration\Code Coloring\
> Macintosh OS 9.X: (default installation location)
Hard disk:Applications:Dreamweaver MX:Configuration:Code Coloring:
2 Create a backup of the CodeColoring.xml file, naming it CodeColoring.xml.bak. Save it in a safe place on your computer.
3 With Dreamweaver MX closed, open CodeColoring.xml in a text editor (Notepad or TextEdit) and make sure Word Wrapping is turned off.
4 You will notice that the XML code in this file is divided by the server models available (ASP-VB, ASP-JS, PHP, etc.). Look for the following lines of code:
 
<scheme name="PHP Script" id="PHP_Script" priority="20">
         <ignoreCase>No</ignoreCase>
         <ignoreTags>Yes</ignoreTags>
         <blockStart name="Block Delimiter" 
id="CodeColor_PHPScriptBlock"
doctypes="PHP_MySQL" scheme="customText">
<![CDATA[<?\s]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?\n]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?php\s]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?php\n]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="outerTag"><![CDATA
[<script\s+language="php">]]></blockStart> <blockEnd><![CDATA[</script>]]></blockEnd>
5 Add the following code to the existing code blocks:
 
<blockStart doctypes="PHP_MySQL" 
scheme="customText"><![CDATA[<?=\s]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?=]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd>

The code in step # 3 should now look similar to this:

<scheme name="PHP Script" id="PHP_Script" priority="20">
     <ignoreCase>No</ignoreCase>
     <ignoreTags>Yes</ignoreTags>
     <blockStart name="Block Delimiter" 
id="CodeColor_PHPScriptBlock" doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?\s]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?=\s]]>
</blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL" scheme="customText"><![CDATA[<?=]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd>
<blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?\n]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?php\s]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="customText"><![CDATA[<?php\n]]></blockStart> <blockEnd><![CDATA[?>]]></blockEnd> <blockStart doctypes="PHP_MySQL"
scheme="outerTag"><![CDATA[<script\s+language="php">]]>
</blockStart> <blockEnd><![CDATA[</script>]]></blockEnd>

Verify everything and check the changes you made. Once verified, save CodeColoring.xml file and restart Dreamweaver MX.

Note: Do not use Dreamweaver MX to edit the XML files. The steps above should be done on all CodeColoring.xml files on the workstation. If other users log into the same computer, you will have to make the changes for each profile.

Additional Information
For more information on Code Coloring, see the article Dreamweaver MX Extensible Code Coloring


ID: 18764
Product: Dreamweaver
Versions: MX, 6.1
OS: All
Browser: All
Server: None
Database: None
Former ID:  
How useful was this document?
less more

1

2

3

4

5

How can the document be improved? (300 characters or less - you will not receive a reply.)

Last updated: July 31, 2003
Created: July 31, 2003